home *** CD-ROM | disk | FTP | other *** search
- /* © 1988-91, Bowers Development Corp. */
- /* Scrolling.c */
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <TextEdit.h>
- #include "Globals.h"
-
- #include "Scrolling.h"
-
- void ScrollingSeg() {}
-
- #pragma segment Scrolling
-
- /*----------*/
- void ResizeScrollBars ()
- {
- Rect contrlRect;
- short curTop;
- short curLeft;
- Rect portRect;
-
- portRect = curWindow->portRect;
- if (cur->vScroll != NULL) {
- contrlRect = (**(cur->vScroll)).contrlRect;
- curTop = contrlRect.top;
- HideControl (cur->vScroll);
- MoveControl (cur->vScroll,
- (portRect.right + 1) - sBarWidth,
- curTop);
- SizeControl (cur->vScroll,
- sBarWidth,
- ((portRect.bottom + 1) - sBarWidth) + 1 - curTop);
- ShowControl (cur->vScroll);
- contrlRect = (**(cur->vScroll)).contrlRect;
- ValidRect (&contrlRect);
- }
-
- if (cur->hScroll != NULL) {
- contrlRect = (**(cur->hScroll)).contrlRect;
- curLeft = contrlRect.left;
- HideControl (cur->hScroll);
- MoveControl (cur->hScroll,
- curLeft,
- (portRect.bottom + 1) - sBarWidth);
- SizeControl (cur->hScroll,
- ((portRect.right + 1) - sBarWidth) + 1 - curLeft,
- sBarWidth);
- ShowControl (cur->hScroll);
- contrlRect = (**(cur->hScroll)).contrlRect;
- ValidRect (&contrlRect);
- }
- } /*ResizeScrollBars*/
-
- /*----------*/
- void DoScrollPart (ControlHandle whichScroll,
- short partCode)
- {
- short pageSize;
- short delta;
- short oldValue;
-
- pageSize = GetCRefCon (whichScroll);
- switch (partCode) {
- case inUpButton:
- delta = -1;
- break;
- case inDownButton:
- delta = 1;
- break;
- case inPageUp:
- delta = -pageSize;
- break;
- case inPageDown:
- delta = pageSize;
- break;
- default:
- delta = 0;
- break;
- } /*switch*/
- if (delta != 0) {
- oldValue = GetCtlValue (whichScroll);
- SetCtlValue (whichScroll, oldValue + delta);
- }
- } /*DoScrollPart*/
-
- /*----------*/
- pascal void ActionGlue (ControlHandle whichScroll,
- short partCode);
- pascal void ActionGlue (ControlHandle whichScroll,
- short partCode)
- {
- short oldValue;
- short newValue;
- ScrollProcPtr actionProc;
-
- oldValue = GetCtlValue (whichScroll);
- DoScrollPart (whichScroll, partCode);
- newValue = GetCtlValue (whichScroll);
- if (newValue != oldValue) {
- actionProc = (ScrollProcPtr) (**whichScroll).contrlAction;
- (*actionProc) (newValue, oldValue);
- }
- } /*ActionGlue*/
-
- /*----------*/
- void TrackScroll (ControlHandle whichScroll,
- short partCode,
- Point where,
- ScrollProcPtr actionProc)
- {
- short oldValue;
- short newValue;
- ControlActionUPP actionUPP;
-
- if (partCode == inThumb) {
- oldValue = GetCtlValue (whichScroll);
- partCode = TrackControl (whichScroll, where, NULL);
- if (actionProc != NULL) {
- newValue = GetCtlValue (whichScroll);
- (*actionProc) (newValue, oldValue);
- }
- } else {
- if (actionProc == NULL) {
- partCode = TrackControl (whichScroll, where, NULL);
- DoScrollPart (whichScroll, partCode);
- } else {
- #ifdef powerc
- (**whichScroll).contrlAction = (UniversalProcPtr) actionProc;
- partCode = TrackControl (whichScroll, where, (UniversalProcPtr) &ActionGlue);
- #else
- (**whichScroll).contrlAction = (ControlActionProcPtr) actionProc;
- actionUPP = NewControlActionProc (ActionGlue);
- partCode = TrackControl (whichScroll, where, actionUPP);
- DisposeRoutineDescriptor ((UniversalProcPtr) actionUPP);
- (**whichScroll).contrlAction = NULL;
- #endif /* powerc */
-
-
- }
- }
- } /*TrackScroll*/
-
- /* Scrolling */
-